package org.example.data_work_demo1.service;

// UserService.java

import org.example.data_work_demo1.mapper.UserMapper;
import org.example.data_work_demo1.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    // 用户注册
    public void registerUser(User user) {
        userMapper.registerUser(user);
    }

    // 用户登录
    public User loginUser(String username, String password) {
        return userMapper.loginUser(username, password);
    }

    // 修改密码
    public void changePassword(Integer userId, String newPassword) {
        userMapper.changePassword(userId, newPassword);
    }

    // 注销用户
    public void deleteUser(Integer userId) {
        userMapper.deleteUser(userId);
    }

    // 更新用户信息
    public void updateUser(User user) {
        userMapper.updateUser(user);
    }
    //显示个人信息
    public User getUserInfo(Integer userId) {
        return userMapper.queryUser(userId);
    }
}
